#製作學員管理系統操作選單, 要能夠查詢、新增、刪除以及退出系統

#自製操作介面，提示1,2,3,4分別的功能
#利用分支結構對四個功能個別處理，以及自己的子介面, 完成後自動返回主畫面
#1查詢:先將學員清單用字典的方式預設好，一個字典代表一個學生，利用格式化輸出 #切記在新增字典時,若KEY是字串時仍然必須添加" ", 否則沒有quot就變成變數了
#2新增:每次新增一個學生，也就是一個字典，
#3刪除:輸入學生id號來del字典
#4退出:break
'''
students_list = [
    {"name":"Blair","gander":"female","habit":"dominating"},
    {"name":"Nate","gander":"male","habit":"daing girls"},
    {"name":"Chuck","gander":"male","habit":"playboy"}
    ]

while True:
    print("="*15+"學員管理系統"+"="*15)
    print("{0:5}{1:<10}{2:<10}{0:5}".format(" ","1、查看學員信息","2、添加學員信息"))
    print("{0:5}{1:<10}{2:<10}{0:5}".format(" ","3、刪除學員信息","4、退出系統"))
    print("="*40)
    key = input("請輸入要操作的項目號碼")
    if key == "1":
        print("="*15+"查看學員信息"+"="*15)
        for i in range(len(students_list)):
            print("{4:<2}{0:3}{1:<8}{2:<8}{3:15}{0:3}".format(" ",students_list[i]["name"],students_list[i]["gander"],students_list[i]["habit"],i+1))
        input("按任意鍵回上頁")
    elif key == "2":
        print("="*15+"添加學員信息"+"="*15)
        a = {}
        a["name"]=input("輸入學員姓名 : ")
        a["gander"]=input("輸入學員性別 : ")
        a["habit"]=input("輸入學員喜好 : ")
        students_list.append(a)
        print("學員信息添加完成")
        input("按任意鍵回上頁")
    elif key == "3":
        print("="*15+"刪除學員信息"+"="*15)
        while True:
             k = int(input("請輸入要刪除的學員ID序號"))
             if k >0 and k <= len(students_list):
                confirm = input("確認刪除"+students_list[k-1]["name"]+"的學員信息嗎? (Y/N)")
                if confirm.lower() == "y":
                    del students_list[k-1]
                    print("完成刪除")
                    break
             
             else:
                print("您輸入的是無效鍵")
    elif key == "4":
        print("再見")
        break
    else:
        print("您輸入的是無效鍵")

'''

#ATM GUI
#step1- Create GUI that shows information of 1 Balance, 2 Withdraw, 3 Deposit, 4 Exit
#step2- Create a list function to call and the GUI starts with the list call, and set current balance = 0
#step3- Create if structure to expand items that been entered.

balance = int()

def is_number(s): # check if it is numeric, yes then returns True.
    try:
        float(s)
        return True
    except ValueError:
        return False
    
def showBalance():
    global balance
    print("")
while True:
    login = input("Please enter your bank account ID : ( numbers only )")
    if not len(login) or not is_number(login): 
        print("Put numbers and numbers only")
        continue
    else:
        passwd = input("Please enter your password : ( numbers only )")
        if not len(passwd) or not is_number(passwd):
            print("Put numbers and numbers only")
            continue
        for i in range(50):
            print("")
        print("Hi, "+ login +" ! Welcome to PYTHON Bank !")
        break
while True:
   
			
    print("="*20+"ATM GUI"+"="*20)
    a = len("="*20+"ATM GUI"+"="*20)
    print("{0:5}{1:<15}{2:<15}{0:5}".format(" ","1.Balance","2.Withdraw"))
    print("{0:5}{1:<15}{2:<15}{0:5}".format(" ","3.Deposit","4.Exit"))
    print("="*a)

    b = input("Please Enter the Number Indicating Above : ")
    if b == "1":
        print("="*20+"Balance GUI"+"="*20)
        a = len("="*20+"Balance GUI"+"="*20)
        print("Your curet balance is : "+str(balance)+" USD")
        print("="*a)
        input("Press any key to return")
    elif b == "2":
        print("="*20+"Withdraw GUI"+"="*20)
        a = len("="*20+"Withdraw GUI"+"="*20)
        print("Your curet balance is : "+str(balance)+" USD")
        print("="*a)
        c = input("Enter the amount you want to withdraw : ")
        if not is_number(c):
            print(c+" is not numeric !")
            continue
        if int(c) > balance:
            print("You don't have enough money...")
            input("Press any key to return")
            continue
        d = input("Is the amount "+c+" correct ? (Y/N) ")
    
        if d.lower() == "y":
            balance -= int(c)
            print("Withdraw completed")
            showBalance()
            input("Press any key to return")
        else:
            continue
    elif b == "3":
        print("="*20+"Deposit GUI"+"="*20)
        a = len("="*20+"Deposit GUI"+"="*20)
        print("Your curet balance is : "+str(balance)+" USD")
        c = input("Enter the amount you want to deposit : ")
        if not is_number(c):
            print(c+" is not numeric !")
            continue
        balance += int(c)
        print("Deposit completed")
        showBalance()
        input("Press any key to return")
    elif b == "4":
        print("Bye Bye")
        break
    else:
        print("Invalid number..")
    
